package com.gxuwz.zhangjiahui.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxuwz.zhangjiahui.entity.Classes;
import com.gxuwz.zhangjiahui.entity.College;
import com.gxuwz.zhangjiahui.service.IClassService;
import com.gxuwz.zhangjiahui.service.ICollegeService;
import org.apache.ibatis.annotations.Param;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 *  文件管理
 * </p>
 *
 * @author zhangjiahui
 * @since 2021-06-20
 */
@RestController
@RequestMapping("/file")
public class PDFController {

    /**
     * 文件上传到项目中
     * @return
     */
    @RequestMapping(value = "/fileOn")
    public void upload(@RequestParam("file") MultipartFile file) throws IOException {
        if(file.isEmpty()){
            System.out.println("上传失败！,请选择文件夹");
        }
        String fileName = file.getOriginalFilename();
        String filePath = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\file\\";
        File dest = new File(filePath + fileName);
        file.transferTo(dest);
    }


}
